  $(function(){
	  //显示权限按钮
	  var parentUUID = $("input[name='parentUUID']").val();
   	  $.permission.showButton(parentUUID,"actionBtnArea");
   	  var dataType = $("input[name='dataType']").val();
   	  //表格初始化
	  $.dataGridEasyUI.initTable({
		  pageId:"#mdDataListPage",
		  gridId:"#mdDataList",
		  url:getBasePath()+'mdData/getMdDataList.do',
		  toolbarId:"#mdDataListPage .tb_toolbar",
		  remoteSort:true,
		  columns:[[
	            {field:'id',checkbox:true},
	            {field:'dataUrl',title:'地址',width:'20%'},
	            {field:'dataTitleVmg',title:'标题',width:400},
	            {field:'validateFlag',title:'校验类型',width:'10%',formatter: function(value,row,index){
	            	if(value==0){
	            		return "<font color=green><b>正常</b></font>";
	            	}else{
	            		return "<font color=green><b>不参与校验</b></font>";
	            	}
				}},
	            {field:'titleGanCi',title:'标题敏感词',width:'10%',formatter: function(value,row,index){
	            	if(value==''){
	            		return "<font color=green><b>无</b></font>";
	            	}
	            	return "<font color=red><b>"+value+"</b></font>";
				}},
	            {field:'pingpaiGanCi',title:'品牌敏感词',width:'10%',formatter: function(value,row,index){
	            	if(value==''){
	            		return "<font color=green><b>无</b></font>";
	            	}
	            	return "<font color=red><b>"+value+"</b></font>";
				}},
	            {field:'creater',title:'上传者',width:'10%'},
	            {field:'createTime',title:'入库时间',width:'11%',sortable:true}
	        ]]
	  });
  
  //新增按钮绑定事件
  $("#addDataLink").bind("click",function(){
	  $.dataGridEasyUI.initEditWindow({
		  url:getBasePath()+"manage/mdData/editMdData.jsp?showType=window",
		  title:"添加会员信息信息",
		  actionType:"add",
		  width:900,
		  height:455
	  });
  });
  
  //更新按钮绑定事件
  $("#updateDataLink").bind("click",function(){
	  $.dataGridEasyUI.initEditWindow({
		  url:getBasePath()+"manage/mdData/editMdData.jsp",
		  title:"编辑词条",
		  actionType:"update",
		  width:650,
		  height:320
	  });
  });
  
  /**
   * 导入数据
   */
  $("#importDataLink").bind("click",function(){
	  $.dataGridEasyUI.initEditWindow({
		  url:getBasePath()+"manage/mdData/importMdData.jsp?showType=window",
		  title:"导入数据",
		  actionType:"add",
		  width:650,
		  height:300
	  });
  });
  
  //批量删除
  $("#batchDeleteLink").bind("click",function(){
	  $.dataGridEasyUI.batchDeleteData({
		  url:getBasePath()+"/mdData/batchDelMdDataForHS.do",
	  });
  });
  
  //单个删除
  $("#singleDeleteLink").bind("click",function(){
	  $.dataGridEasyUI.batchDeleteData({
		  url:getBasePath()+"/mdData/delMdData.do",
	  });
  });
  
  //显示详情
  $("#showDetailLink").bind("click",function(){
	  $.dataGridEasyUI.initEditWindow({
		  url:getBasePath() + "manage/mdData/adminDetail.jsp",
		  title:"展示详情",
		  actionType:"detail",
		  width:650,
		  height:350
	  });
  });
  
  $("#searchBtn").click(function(){
	  seachData();
  });

})

//永久删除数据
function batchDelInDB(){
  $.dataGridEasyUI.batchDeleteInDB({
	  url:getBasePath()+"/mdData/batchDelMdData.do",
  });
}
         
         
 //恢复数据
function rebackData(){
	$.dataGridEasyUI.batchDeleteInDB({
		  url:getBasePath()+"/mdData/batchRebackData.do"
	});
}

function clearData(){
	$.dataGridEasyUI.batchDeleteInDB({
		url:getBasePath()+"/mdData/clearData.do"
	});
}

handToBatchData()


//检索数据
function seachData(){
   var searChObj = new Object(); 
   var formId = "searchForm";
   $("#"+formId).find("input").each(function(i){
	   searChObj[$(this).attr("name")] = $(this).val();
   });
   
   $("#"+formId).find("select").each(function(i){
	   searChObj[$(this).attr("name")] = $(this).val();
   });
   tableObject.datagrid({
	     queryParams:searChObj
   })
}
